import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/accounts/login/',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/accounts/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/accounts/logout/',
    method: 'post'
  })
}

export function fetchList(query) {
  return request({
    url: '/account/list',
    method: 'get',
    params: query
  })
}

export function updateUser(data) {
  return request({
    url: '/account/update',
    method: 'post',
    data
  })
}

export function createUser(data) {
  return request({
    url: '/account/create',
    method: 'post',
    data
  })
}

export function delUser(user_id) {
  return request({
    url: '/account/delUser/' + user_id,
    method: 'get'
  })
}

export function getChildrens(user_id) {
  return request({
    url: '/account/getChildrens/' + user_id,
    method: 'get'
  })
}

export function getTree() {
  return request({
    url: '/account/getTree',
    method: 'get'
  })
}

export function getLeaf(id) {
  return request({
    url: '/account/getLeaf/' + id,
    method: 'get'
  })
}

export function getAllInfo() {
  return request({
    url: '/manager/version/list/',
    method: 'get'
  })
}
